<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('diyfield_list');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>自定义字段 </title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<link href="templates/css/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/layindex.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
<script type="text/javascript">
	function getVal(id)
	{

				$.ajax({
					url : "ajax_do.php",
					type:'post',
					data:{"action":"diyfieldorderid", "orderid":document.getElementById(id).value,"pid":document.getElementsByName(id)[0].getAttribute("pid")},
					dataType:'html',
					success:function(data){	
					}
				});
				
	}
	
	function func(id){
	//获取被选中的option标签
		var vs = $('#'+id+' option:selected').val();
		if(vs>=0){
		location.href = "diyfield.php?cid="+vs;}
		else{
			
			location.href = "diyfield.php";
		}
	}

	
</script>
</head>

<body class="mainbody">

<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>自定义字段</span>
  <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"></a>
      <div class="l-list">
        <ul class="icon-list">
          <li><a class="add" href="diyfield_add.php"><i></i><span>添加新字段</span></a></li>
        </ul>
		 <div class="menu-list">
          <div class="rule-single-select">
          <select name="diymod" onchange="javascript:func('diymod')" id="diymod">
		<option selected="selected" value="-1">全部模型...</option>
			<?php
				//初始化类型
				$infotype = isset($infotype) ? $infotype : '';
				$cid = !isset($cid) ? '-1': $cid;
				foreach(array('0'=>'单页','1'=>'列表','4'=>'商品') as $k=>$v)
				{	if(@$cid==$k) $select='selected="selected"';else $select='';
					echo '<option '.$select.' value="'.$k.'">'.$v.'</option>';	
				}
				$dosql->Execute("select * from `#@__diymodel` where checkinfo='true'");
					while($rows=$dosql->GetArray())
					{	if(@$cid==$rows['id']) $select='selected="selected"';else $select='';
						echo '<option '.$select.'  value="'.$rows['id'].'">'.$rows['modeltitle'].'</option>';	
					}
				?>
		</select>

          </div>
        
        </div>
      </div>
      
    </div>
  </div>
</div>
<!--/工具栏-->
<form name="form" id="form" method="post" action="diyfield_save.php">
<!--列表-->
<div class="table-container">
  
  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
      <th width="8%">ID</th>
      <th align="left" width="15%">字段名称</th>
      <th align="left" >标识</th>
      <th align="left">类型</th>
      <th align="left">所属模型</th>
      <th width="8%">排序</th>
      <th width="8%">操作</th>
    </tr>
<?php
		$sql = "SELECT * FROM `#@__diyfield`";
		if($cid>=0 ) $sql .= "WHERE infotype=$cid";	
		$dopage->GetPage($sql,'','ASC','orderid');
		while($row = $dosql->GetArray())
		{
			switch($row['infotype'])
			{
				case 0:
					$infotype = '单页';
					break;  
				case 1:
					$infotype = '列表';
					break;
				case 4:
					$infotype = '商品';
					break;

				default:
					$r = $dosql->GetOne("SELECT * FROM `#@__diymodel` WHERE `id`=".$row['infotype']);
					if(isset($r) && is_array($r))
						$infotype = $r['modeltitle'];
					else
						$infotype = '没有获取到类型';
			}


			switch($row['checkinfo'])
			{
				case 'true':
					$checkinfo = '启用';
					break;  
				case 'false':
					$checkinfo = '禁用';
					break;
				default:
					$checkinfo = '没有获取到参数';
			}
		?>
		<tr  >
			<td align="center"><?php echo $row['id']; ?></td>
			<td><?php echo $row['fieldname']; ?></td>
			<td><?php echo $row['fieldtitle']; ?></td>
			<td><?php echo $row['fieldtype']; ?></td>
			<td ><?php echo $infotype; ?></td>
		<td width="10%" align="center">
		<input type="text" name="orderid[<?php echo $row['id']; ?>]" pid="<?php echo $row['id']; ?>" id="orderid[<?php echo $row['id']; ?>]" class="sort" onblur="getVal(this.id)" value="<?php echo $row['orderid']; ?>" />
		</td>
		<td width="12%"align="center" ><span><a href="diyfield_save.php?action=check&id=<?php echo $row['id']; ?>&checkinfo=<?php echo $row['checkinfo']; ?>" title="点击进行审核与未审操作"><?php echo $checkinfo; ?></a></span> | <span><a href="diyfield_update.php?id=<?php echo $row['id']; ?>">修改</a></span> | <span class="nb"><a href="diyfield_save.php?action=del&infotype=<?php echo $row['infotype']; ?>&id=<?php echo $row['id']; ?>&fieldname=<?php echo $row['fieldname']; ?>" onclick="return ConfDel(0)">删除</a></span></td>		</tr>
		<?php
		
		}
		?>
			<?php
			//判断无记录样式
	
	
	
if($dosql->GetTotalRow() == 0)
{
	echo '<tr><td align="center" colspan="7">暂无记录</td></tr>';
}
?>

  </table>
  
</div>
<!--/列表-->

<!--内容底部-->
<div class="line20"></div>
<div class="pagelist"  >
 
  <?php echo $dopage->GetList($sql); ?>

</div>
<!--/内容底部-->
</form>
</body>
</html>
